package com.biu.billiards.controller;

import com.biu.billiards.model.vo.dyVo.AddDyVo;
import com.biu.billiards.model.vo.dyVo.GetDyVo;
import com.biu.billiards.model.vo.dyVo.UpdateDyVO;
import com.biu.billiards.model.vo.mt.AddMtVo;
import com.biu.billiards.model.vo.mt.GetMtVo;
import com.biu.billiards.model.vo.mt.UpdateMtVO;
import com.biu.billiards.response.BaseResponse;
import com.biu.billiards.response.RespGenerator;
import com.biu.billiards.service.IDyService;
import com.biu.billiards.service.IMtService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xue
 * @since 2023-09-25
 */
@RestController
@RequestMapping()
public class MtController {



    @Resource
    private IMtService mtService;




    @ApiOperation(value = "美团授权")
    @GetMapping("/mtAuth")
    public BaseResponse<Map<String,Object>> mtAuth(@RequestParam("auth_code") String authCode,
                                                   @RequestParam("state") Integer state) {

        System.out.println("美团授权");
        System.out.println(authCode);
        System.out.println(state);

        GetMtVo getMtVo =new GetMtVo();
        getMtVo.setMtId(state);
        getMtVo.setAuthCode(authCode);


        return RespGenerator.returnOK(mtService.mtAuth(getMtVo));
    }

    @ApiOperation(value = "获取美团配置数据")
    @PostMapping("/getMtPage")
    public BaseResponse<Map<String,Object>> getMtPage(@RequestBody GetMtVo getMtVo) {
        return RespGenerator.returnOK(mtService.getMtPage(getMtVo));
    }


    @ApiOperation(value = "修改美团配置信息")
    @PutMapping("/updateMt")
    public BaseResponse<Boolean> updateMt(@RequestBody UpdateMtVO updateDyVO) {
        return RespGenerator.returnOK(mtService.updateMt(updateDyVO));
    }


    @ApiOperation(value = "新增美团配置信息")
    @PostMapping("/addMt")
    public BaseResponse<Boolean> addMt(@RequestBody AddMtVo addDyVo) {
        return RespGenerator.returnOK(mtService.addMt(addDyVo));
    }


    @ApiOperation(value = "删除美团配置信息")
    @DeleteMapping("/deleteMt")
    public BaseResponse<Boolean> deleteMt(@RequestParam("mtId") Integer dyId) {
        return RespGenerator.returnOK(mtService.deleteMt(dyId));
    }










}
